import java.util.*;

public class java7 {


    public static void main(String[] args) {
        int maxn = 1000012;
        int[] nextval = new int[maxn];
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String p = sc.next();
        boolean found = false;

        // 构造 next 数组
        nextval[0] = 0;
        for (int i = 1, j = 0; i < p.length(); i++) {
            while (j > 0 && p.charAt(j) != p.charAt(i)) {
                j = nextval[j - 1];
            }
            if (p.charAt(j) == p.charAt(i)) {
                j++;
            }
            nextval[i] = j;
        }

        // KMP 查找匹配
        for (int i = 0, j = 0; i < s.length(); i++) {
            while (j > 0 && s.charAt(i) != p.charAt(j)) {
                j = nextval[j - 1];
            }
            if (s.charAt(i) == p.charAt(j)) {
                j++;
            }
            if (j == p.length()) {
                found = true;
                System.out.printf("%d\n", i - p.length() + 1);
                j = nextval[j - 1];
            }
        }

        if (!found) {
            System.out.println(-1);
        }

        sc.close();
    }
}
